package cn.edu.ujs.coor.repository.relation;

import cn.edu.ujs.coor.model.Access;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public interface AccessRepository extends JpaRepository<Access, String>, JpaSpecificationExecutor<Access> {

    /**
     * 根据角色编号查询节点编号
     * @param roleId
     * @return
     */
    @Query(value = "select node_id from coor_access where role_id = ?1", nativeQuery = true)
    List<String> findByRoleId (String roleId);

    /**
     * 根据角色编号删除关联
     * @param roleId
     */
    void deleteByRoleId (String roleId);

    /**
     * 根据节点编号删除关联
     * @param nodeId
     */
    void deleteByNodeId (String nodeId);
}
